<?php
	
	if (!defined('EXPONENT')) exit('');

	$company = null;
	$id = 0;
	if(isset($_REQUEST['id']))
	{
		$id = intval($_REQUEST['id']); 
		$company = $db->selectObject('surveymodule_companies',"id=".$id);
		$loc=unserialize($company->location_data);
	}
	if (exponent_permissions_check(array('administrate','configure', "create"),$loc)) {

		$company = surveymodule_cat::company_update($_POST,$company);
		$company->location_data = serialize($loc);
		
		if (isset($company->id)) {
			$db->updateObject($company,'surveymodule_companies');
		} else {
			$db->insertObject($company,'surveymodule_companies');
		}

		exponent_flow_redirect();
	} else {
		echo SITE_404_HTML;
	}

?>